package com.triones.framework.common.util.weixin;

import java.util.*;

public class SignUtils {

    /**
     * 获取签名
     * @param parameters
     * @return
     */
    public static String creatSign(SortedMap<Object, Object> parameters) {
        StringBuffer sb = new StringBuffer();
        Set es = parameters.entrySet();
        Iterator it = es.iterator();
        while(it.hasNext()) {
            Map.Entry entry = (Map.Entry)it.next();
            String k = (String)entry.getKey();
            Object v = entry.getValue();
            if(null != v && !"".equals(v)
                && !"sign".equals(k) && !"key".equals(k)) {
                sb.append(k + "=" + v + "&");
            }
        }
        sb.append("key=fdf35dgf5dfhdy6tsgfst56fgh546rgf");
        String sign = MD5Utils.MD5Encode(sb.toString(), "UTF-8").toUpperCase();
        System.out.println(sign);
        return sign;
    }
}

